﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wp.BLL;
using Wp.DAL;


public partial class Admin_Modules_Categories_Default : System.Web.UI.Page
{
    public static int PAGE_SIZE = 50;
    public int PageIndex { get; set; }
    public string Taxonomy = "category";
    protected void Page_Load(object sender, EventArgs e)
    {
        PageIndex = CommonHelper.QueryStringInt("PageIndex", 1);
        if (!IsPostBack)
        {
            LoadData();
        }
    }

    private void LoadData()
    {
        List<TblTermTaxonomyEntity> ls = new List<TblTermTaxonomyEntity>();
        ls = TblTermTaxonomyManager.CreateInstant().SelectTblTermsTaxonomyGetChildFormat(null, Taxonomy);
        ddlparent.DataSource = ls;
        ddlparent.DataTextField = "Name";
        ddlparent.DataValueField = "Id";
        ddlparent.DataBind();
        rpt.DataSource = ls.Skip((PageIndex - 1) * PAGE_SIZE).Take(PAGE_SIZE); ;
        rpt.DataBind();
        int TotalRow = ls.Count;
        smartPager1.PageSize = smartPager.PageSize = PAGE_SIZE;
        smartPager1.QueryStringKey = smartPager.QueryStringKey = "PageIndex";
        smartPager1.RowCount = smartPager.RowCount = TotalRow;
        smartPager1.NavigatePreviousText = smartPager.NavigatePreviousText = "<<";
        smartPager1.NavigateNextText = smartPager.NavigateNextText = ">>";
        //smartPager.Display=3;
        smartPager1.UrlFormatString = smartPager.UrlFormatString = "/Admin/Modules/Categories/Default.aspx?PageIndex={0}";
        smartPager1.Visible = smartPager.Visible = TotalRow > PAGE_SIZE;
    }
}